import{t as W,j as e,l as r,T as p,B as c,h as y,v as I,r as S,F as M,m,w as F,M as L,n as l,o as j,x as w,y as q,z}from"./index-aaf7dbcc.js";import{C as O,a as H,d as _,L as C}from"./Loading-ac930979.js";const B=({task:t})=>{const n=i=>{i.dataTransfer.setData("cardInfo",JSON.stringify({id:t.id,status:t.status}))},[d,{}]=W(),u=()=>d({taskId:t.id});return e(O,{sx:{mb:3,minHeight:120,width:300},draggable:!0,onDragStart:n,children:r(H,{children:[e(p,{variant:"h4",children:t.title}),e(p,{children:t.description}),e(p,{children:t.final_date.toLocaleString()}),e(c,{onClick:u,children:"Удалить"})]})},t.id)},E=({boardId:t,status:n,tasks:d,changeTaskStatus:u})=>{const{register:i,handleSubmit:f}=y(),[g,{isLoading:h}]=I(),k=a=>g({boardId:parseInt(t),taskDescription:a.taskDescription,taskTitle:a.taskTitle,taskFinalData:a.taskFinalData,taskStatus:n}),[x,o]=S.useState(!1),b=()=>o(!0),D=()=>o(!1),T=a=>{u(a.dataTransfer.getData("cardInfo"),n)},s=a=>{a.preventDefault()};return r(M,{children:[r(m,{sx:{mr:3,alignItems:"center"},onDrop:T,onDragEnter:s,onDragLeave:s,onDragOver:s,children:[e(p,{variant:"h5",align:"center",children:n}),r(m,{marginTop:2,children:[d.map(a=>e(B,{task:a},a.id)),e(O,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:120,width:300},children:e(c,{sx:{height:"100%",width:"100%"},onClick:b,children:h?e(F,{fontSize:"large"}):e(_,{fontSize:"large"})})})]})]}),e(L,{open:x,onClose:D,sx:{display:"flex",justifyContent:"center",mt:20},children:r(m,{component:"form",onSubmit:f(k),sx:{background:"white",width:400,maxHeight:400,display:"flex",justifyContent:"center",alignItems:"center",flexDirection:"column",borderRadius:2,p:2},children:[e(l,{sx:{mb:2},required:!0,label:"Название задачи",autoFocus:!0,...i("taskTitle"),fullWidth:!0}),e(l,{sx:{mb:2},required:!0,label:"Описание задачи",...i("taskDescription"),fullWidth:!0}),e(l,{sx:{mb:2},required:!0,...i("taskFinalData"),type:"date",fullWidth:!0}),e(c,{variant:"outlined",type:"submit",fullWidth:!0,children:"Подтвердить"})]})})]})},P=S.lazy(()=>j(()=>import("./Layout-ef000408.js"),["assets/Layout-ef000408.js","assets/index-aaf7dbcc.js"])),N=()=>{const{id:t}=w();if(!t)return e(C,{});const{register:n,handleSubmit:d}=y(),[u,{isLoading:i}]=I(),f=s=>u({boardId:parseInt(t),taskDescription:s.taskDescription,taskTitle:s.taskTitle,taskFinalData:s.taskFinalData,taskStatus:s.taskStatus}),[g,h]=S.useState(!1),k=()=>h(!0),x=()=>h(!1),{data:o,isLoading:b}=q({boardId:parseInt(t)}),[D,{}]=z(),T=(s,a)=>{const v=JSON.parse(s);D({taskId:v.id,newStatus:a})};return r(M,{children:[r(P,{children:[b?e(C,{}):o==null?void 0:o.map((s,a)=>e(E,{boardId:t,status:s.status,tasks:s.tasks,changeTaskStatus:T},a)),e(c,{sx:{ml:3},onClick:k,children:i?e(F,{fontSize:"large"}):e(_,{fontSize:"large"})})]}),e(L,{open:g,onClose:x,sx:{display:"flex",justifyContent:"center",mt:20},children:r(m,{component:"form",onSubmit:d(f),sx:{background:"white",width:300,maxHeight:400,display:"flex",justifyContent:"center",alignItems:"center",flexDirection:"column",borderRadius:2,p:2},children:[e(l,{sx:{mb:2},required:!0,label:"Название задачи",autoFocus:!0,...n("taskTitle"),fullWidth:!0}),e(l,{sx:{mb:2},required:!0,label:"Описание задачи",...n("taskDescription"),fullWidth:!0}),e(l,{sx:{mb:2},required:!0,label:"Статус задачи",...n("taskStatus"),fullWidth:!0}),e(l,{sx:{mb:2},required:!0,...n("taskFinalData"),type:"date",fullWidth:!0}),e(c,{type:"submit",fullWidth:!0,children:"Добавить"})]})})]})};export{N as default};
